TARGT = mytry


TOPDIR := $(CURDIR)
export	TOPDIR

AS              = $(CROSS_COMPILE)as
LD              = $(CROSS_COMPILE)ld
CC              = $(CROSS_COMPILE)gcc
AR              = $(CROSS_COMPILE)ar
NM              = $(CROSS_COMPILE)nm
STRIP           = $(CROSS_COMPILE)strip
OBJCOPY         = $(CROSS_COMPILE)objcopy
OBJDUMP         = $(CROSS_COMPILE)objdump
export	AS LD CC NM STRIP OBJCOPY OBJDUMP

CFLAGS := -O2 -Wall -fomit-frame-pointer 
AFLAGS := -O2 -Wall -fomit-frame-pointer -D__ASSEMBLY__
export	CFLAGS AFLAGS

SUBDIRS	= base trans hw debug
.PHONY : $(SUBDIRS)


OBJS_ALL	+= built-in.o
OBJS_ALL	+= base/built-in.o
OBJS_ALL	+= trans/built-in.o
OBJS_ALL	+= hw/built-in.o
OBJS_ALL	+= debug/built-in.o

all:	$(TARGT)	

$(TARGT): $(SUBDIRS) $(OBJS_ALL)
	$(CC) $(LDFLAGS) -o $@ $(OBJS_ALL)
	$(NM) -v -l $@ > $(TARGT).map

clean:
	rm -rf *.o .depend *.map $(TARGT)
	rm -rf ./hw/*.o ./hw/.depend
	rm -rf ./base/*.o ./base/.depend
	rm -rf ./trans/*.o ./trans/.depend
	rm -rf ./debug/*.o ./debug/.depend

$(SUBDIRS):
	$(MAKE) -C $@ all

COBJS-y	+= main.o loader.o cpu.o ioport.o block_dev.o
include $(TOPDIR)/config.mk

